package com.woniuxy.homepage.core.controller;


import com.woniuxy.common.CommonResult;
import com.woniuxy.homepage.core.model.CarGoodsActivity;
import com.woniuxy.homepage.core.service.CarGoodsActivityService;
import com.woniuxy.homepage.core.vo.CarGoodsActivityVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gmx
 * @since 2021-07-03
 */
@RestController
@RequestMapping("carGoodsActivity")
@Api(tags = "活动商品接口")
public class CarGoodsActivityController {

    @Resource
    private CarGoodsActivityService carGoodsActivityService;


    /**
     * Description : 查询活动商品  <br/>
     * ChangeLog : 1. 创建 (2021/7/3 14:32 [Hello Mr. Guo]);
     *
     * @return com.woniuxy.common.CommonResult
    */
    @GetMapping("selectGoodsActivity/{count}")
    @ApiOperation("查询活动商品")
    public CommonResult selectGoodsActivity(@PathVariable("count")int count){
        List<CarGoodsActivityVo> list = this.carGoodsActivityService.selectAll(count);
        if (list == null){
            return CommonResult.fail("查询活动商品失败");
        }
        return CommonResult.success(list);
    }

    /**
     * Description : 购买活动商品  <br/>
     * ChangeLog : 1. 创建 (2021/7/5 10:52 [Hello Mr. Guo]);
     * @param goodsId
     * @return com.woniuxy.common.CommonResult
    */
    @GetMapping("buyActivityGoods")
    @ApiOperation("购买活动商品")
    public CommonResult buyActivityGoods(Integer goodsId,Integer userId){
        int i = this.carGoodsActivityService.buyActivityGoods(goodsId,userId);
        return CommonResult.success();
    }
}

